package com.tapjoy;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class TapjoyUtil
{
  private static final String TAPJOY_UTIL = "TapjoyUtil";

  public static String SHA1(String paramString)
    throws NoSuchAlgorithmException, UnsupportedEncodingException
  {
    return hashAlgorithm("SHA-1", paramString);
  }

  public static String SHA256(String paramString)
    throws NoSuchAlgorithmException, UnsupportedEncodingException
  {
    return hashAlgorithm("SHA-256", paramString);
  }

  public static Document buildDocument(String paramString)
  {
    try
    {
      DocumentBuilderFactory localDocumentBuilderFactory = DocumentBuilderFactory.newInstance();
      ByteArrayInputStream localByteArrayInputStream = new ByteArrayInputStream(paramString.getBytes("UTF-8"));
      Document localDocument = localDocumentBuilderFactory.newDocumentBuilder().parse(localByteArrayInputStream);
      return localDocument;
    }
    catch (Exception localException)
    {
      TapjoyLog.e("TapjoyUtil", "buildDocument exception: " + localException.toString());
    }
    return null;
  }

  private static String convertToHex(byte[] paramArrayOfByte)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    int i = 0;
    int j;
    if (i < paramArrayOfByte.length)
      j = 0xF & paramArrayOfByte[i] >>> 4;
    int m;
    label94: for (int k = 0; ; k = m)
    {
      if ((j >= 0) && (j <= 9))
        localStringBuffer.append((char)(j + 48));
      while (true)
      {
        j = 0xF & paramArrayOfByte[i];
        m = k + 1;
        if (k < 1)
          break label94;
        i++;
        break;
        localStringBuffer.append((char)(97 + (j - 10)));
      }
      return localStringBuffer.toString();
    }
  }

  public static Bitmap createBitmapFromView(View paramView)
  {
    Bitmap localBitmap = Bitmap.createBitmap(paramView.getLayoutParams().width, paramView.getLayoutParams().height, Bitmap.Config.ARGB_8888);
    Canvas localCanvas = new Canvas(localBitmap);
    paramView.layout(paramView.getLeft(), paramView.getTop(), paramView.getRight(), paramView.getBottom());
    paramView.draw(localCanvas);
    return localBitmap;
  }

  public static void deleteFileOrDirectory(File paramFile)
  {
    if (paramFile.isDirectory())
    {
      File[] arrayOfFile = paramFile.listFiles();
      int i = arrayOfFile.length;
      for (int j = 0; j < i; j++)
        deleteFileOrDirectory(arrayOfFile[j]);
    }
    TapjoyLog.i("TapjoyUtil", "****************************************");
    TapjoyLog.i("TapjoyUtil", "deleteFileOrDirectory: " + paramFile.getAbsolutePath());
    TapjoyLog.i("TapjoyUtil", "****************************************");
    paramFile.delete();
  }

  public static String getNodeTrimValue(NodeList paramNodeList)
  {
    Element localElement = (Element)paramNodeList.item(0);
    String str1 = "";
    String str2 = null;
    if (localElement != null)
    {
      NodeList localNodeList = localElement.getChildNodes();
      int i = localNodeList.getLength();
      for (int j = 0; j < i; j++)
      {
        Node localNode = localNodeList.item(j);
        if (localNode != null)
          str1 = str1 + localNode.getNodeValue();
      }
      str2 = null;
      if (str1 != null)
      {
        boolean bool = str1.equals("");
        str2 = null;
        if (!bool)
          str2 = str1.trim();
      }
    }
    return str2;
  }

  public static String hashAlgorithm(String paramString1, String paramString2)
    throws NoSuchAlgorithmException, UnsupportedEncodingException
  {
    new byte[40];
    MessageDigest localMessageDigest = MessageDigest.getInstance(paramString1);
    localMessageDigest.update(paramString2.getBytes("iso-8859-1"), 0, paramString2.length());
    return convertToHex(localMessageDigest.digest());
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.tapjoy.TapjoyUtil
 * JD-Core Version:    0.6.2
 */